home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows (5th Edition) / Programming Windows, 5th ed. - Companion CD (097-0002183)(1999).iso / Chap17 / PickFont / PickFont.c next >
Encoding:
C/C++ Source or Header  |  1998-10-09  |  18.0 KB  |  500 lines

  1. /*-----------------------------------------
  2.    PICKFONT.C -- Create Logical Font
  3.                  (c) Charles Petzold, 1998
  4.   -----------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include "resource.h"
  8.  
  9.      // Structure shared between main window and dialog box
  10.  
  11. typedef struct
  12. {
  13.      int        iDevice, iMapMode ;
  14.      BOOL       fMatchAspect ;
  15.      BOOL       fAdvGraphics ;
  16.      LOGFONT    lf ;
  17.      TEXTMETRIC tm ;
  18.      TCHAR      szFaceName [LF_FULLFACESIZE] ;
  19. }
  20. DLGPARAMS ;
  21.  
  22.      // Formatting for BCHAR fields of TEXTMETRIC structure
  23.  
  24. #ifdef UNICODE
  25. #define BCHARFORM TEXT ("0x%04X")
  26. #else
  27. #define BCHARFORM TEXT ("0x%02X")
  28. #endif
  29.  
  30.      // Global variables
  31.  
  32. HWND  hdlg ;
  33. TCHAR szAppName[] = TEXT ("PickFont") ;
  34.  
  35.      // Forward declarations of functions
  36.  
  37. LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
  38. BOOL    CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM) ;
  39. void SetLogFontFromFields    (HWND hdlg, DLGPARAMS * pdp) ;
  40. void SetFieldsFromTextMetric (HWND hdlg, DLGPARAMS * pdp) ;
  41. void MySetMapMode (HDC hdc, int iMapMode) ;
  42.  
  43. int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
  44.                     PSTR szCmdLine, int iCmdShow)
  45. {
  46.      HWND     hwnd ;
  47.      MSG      msg ;
  48.      WNDCLASS wndclass ;
  49.      
  50.      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
  51.      wndclass.lpfnWndProc   = WndProc ;
  52.      wndclass.cbClsExtra    = 0 ;
  53.      wndclass.cbWndExtra    = 0 ;
  54.      wndclass.hInstance     = hInstance ;
  55.      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
  56.      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
  57.      wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
  58.      wndclass.lpszMenuName  = szAppName ; 
  59.      wndclass.lpszClassName = szAppName ;
  60.      
  61.      if (!RegisterClass (&wndclass))
  62.      {
  63.           MessageBox (NULL, TEXT ("This program requires Windows NT!"),
  64.                szAppName, MB_ICONERROR) ;
  65.           return 0 ;
  66.      }
  67.      
  68.      hwnd = CreateWindow (szAppName, TEXT ("PickFont: Create Logical Font"),
  69.                           WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  70.                           CW_USEDEFAULT, CW_USEDEFAULT,
  71.                           CW_USEDEFAULT, CW_USEDEFAULT,
  72.                           NULL, NULL, hInstance, NULL) ;
  73.      
  74.      ShowWindow (hwnd, iCmdShow) ;
  75.      UpdateWindow (hwnd) ;
  76.      
  77.      while (GetMessage (&msg, NULL, 0, 0))
  78.      {
  79.           if (hdlg == 0 || !IsDialogMessage (hdlg, &msg))
  80.           {
  81.                TranslateMessage (&msg) ;
  82.                DispatchMessage (&msg) ;
  83.           }
  84.      }
  85.      return msg.wParam ;
  86. }
  87.  
  88. LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  89. {
  90.      static DLGPARAMS dp ;
  91.      static TCHAR     szText[] = TEXT ("\x41\x42\x43\x44\x45 ")
  92.                                  TEXT ("\x61\x62\x63\x64\x65 ")
  93.  
  94.                                  TEXT ("\xC0\xC1\xC2\xC3\xC4\xC5 ")
  95.                                  TEXT ("\xE0\xE1\xE2\xE3\xE4\xE5 ") 
  96. #ifdef UNICODE
  97.                                  TEXT ("\x0390\x0391\x0392\x0393\x0394\x0395 ")
  98.                                  TEXT ("\x03B0\x03B1\x03B2\x03B3\x03B4\x03B5 ")
  99.  
  100.                                  TEXT ("\x0410\x0411\x0412\x0413\x0414\x0415 ")
  101.                                  TEXT ("\x0430\x0431\x0432\x0433\x0434\x0435 ")
  102.  
  103.                                  TEXT ("\x5000\x5001\x5002\x5003\x5004") 
  104. #endif
  105.                                  ;
  106.      HDC              hdc ;
  107.      PAINTSTRUCT      ps ;
  108.      RECT             rect ;
  109.      
  110.      switch (message)
  111.      {
  112.      case WM_CREATE:
  113.           dp.iDevice = IDM_DEVICE_SCREEN ;
  114.  
  115.           hdlg = CreateDialogParam (((LPCREATESTRUCT) lParam)->hInstance, 
  116.                                     szAppName, hwnd, DlgProc, (LPARAM) &dp) ;
  117.           return 0 ;
  118.  
  119.      case WM_SETFOCUS:
  120.           SetFocus (hdlg) ;
  121.           return 0 ;
  122.  
  123.      case WM_COMMAND:
  124.           switch (LOWORD (wParam))
  125.           {
  126.           case IDM_DEVICE_SCREEN:
  127.           case IDM_DEVICE_PRINTER:
  128.                CheckMenuItem (GetMenu (hwnd), dp.iDevice, MF_UNCHECKED) ;
  129.                dp.iDevice = LOWORD (wParam) ;
  130.                CheckMenuItem (GetMenu (hwnd), dp.iDevice, MF_CHECKED) ;
  131.                SendMessage (hwnd, WM_COMMAND, IDOK, 0) ;
  132.                return 0 ;
  133.           }
  134.           break ;
  135.  
  136.      case WM_PAINT:
  137.           hdc = BeginPaint (hwnd, &ps) ;
  138.  
  139.                // Set graphics mode so escapement works in Windows NT
  140.  
  141.           SetGraphicsMode (hdc, dp.fAdvGraphics ? GM_ADVANCED : GM_COMPATIBLE) ;
  142.  
  143.                // Set the mapping mode and the mapper flag
  144.  
  145.           MySetMapMode (hdc, dp.iMapMode) ;
  146.           SetMapperFlags (hdc, dp.fMatchAspect) ;
  147.  
  148.                // Find the point to begin drawing text
  149.  
  150.           GetClientRect (hdlg, &rect) ;
  151.           rect.bottom += 1 ;
  152.           DPtoLP (hdc, (PPOINT) &rect, 2) ;
  153.  
  154.                // Create and select the font; display the text
  155.  
  156.           SelectObject (hdc, CreateFontIndirect (&dp.lf)) ;
  157.           TextOut (hdc, rect.left, rect.bottom, szText, lstrlen (szText)) ;
  158.  
  159.           DeleteObject (SelectObject (hdc, GetStockObject (SYSTEM_FONT))) ;
  160.           EndPaint (hwnd, &ps) ;
  161.           return 0 ;
  162.           
  163.      case WM_DESTROY:
  164.           PostQuitMessage (0) ;
  165.           return 0 ;
  166.      }
  167.      return DefWindowProc (hwnd, message, wParam, lParam) ;
  168. }
  169.  
  170. BOOL CALLBACK DlgProc (HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
  171. {
  172.      static DLGPARAMS * pdp ;
  173.      static PRINTDLG    pd = { sizeof (PRINTDLG) } ;
  174.      HDC                hdcDevice ;
  175.      HFONT              hFont ;
  176.      
  177.      switch (message)
  178.      {
  179.      case WM_INITDIALOG:
  180.                // Save pointer to dialog-parameters structure in WndProc
  181.  
  182.           pdp = (DLGPARAMS *) lParam ;
  183.  
  184.           SendDlgItemMessage (hdlg, IDC_LF_FACENAME, EM_LIMITTEXT, 
  185.                                     LF_FACESIZE - 1, 0) ;
  186.  
  187.           CheckRadioButton (hdlg, IDC_OUT_DEFAULT, IDC_OUT_OUTLINE,
  188.                                   IDC_OUT_DEFAULT) ;
  189.  
  190.           CheckRadioButton (hdlg, IDC_DEFAULT_QUALITY, IDC_PROOF_QUALITY,
  191.                                   IDC_DEFAULT_QUALITY) ;
  192.  
  193.           CheckRadioButton (hdlg, IDC_DEFAULT_PITCH, IDC_VARIABLE_PITCH,
  194.                                   IDC_DEFAULT_PITCH) ;
  195.  
  196.           CheckRadioButton (hdlg, IDC_FF_DONTCARE, IDC_FF_DECORATIVE,
  197.                                   IDC_FF_DONTCARE) ;
  198.  
  199.           CheckRadioButton (hdlg, IDC_MM_TEXT, IDC_MM_LOGTWIPS,
  200.                                   IDC_MM_TEXT) ;
  201.  
  202.           SendMessage (hdlg, WM_COMMAND, IDOK, 0) ;
  203.  
  204.                                    // fall through
  205.      case WM_SETFOCUS:
  206.           SetFocus (GetDlgItem (hdlg, IDC_LF_HEIGHT)) ;
  207.           return FALSE ;
  208.  
  209.      case WM_COMMAND:
  210.           switch (LOWORD (wParam))
  211.           {
  212.           case IDC_CHARSET_HELP:
  213.                MessageBox (hdlg, 
  214.                            TEXT ("0 = Ansi\n")
  215.                            TEXT ("1 = Default\n")
  216.                            TEXT ("2 = Symbol\n")
  217.                            TEXT ("128 = Shift JIS (Japanese)\n")
  218.                            TEXT ("129 = Hangul (Korean)\n")
  219.                            TEXT ("130 = Johab (Korean)\n")
  220.                            TEXT ("134 = GB 2312 (Simplified Chinese)\n")
  221.                            TEXT ("136 = Chinese Big 5 (Traditional Chinese)\n")
  222.                            TEXT ("177 = Hebrew\n")
  223.                            TEXT ("178 = Arabic\n")
  224.                            TEXT ("161 = Greek\n")
  225.                            TEXT ("162 = Turkish\n")
  226.                            TEXT ("163 = Vietnamese\n")
  227.                            TEXT ("204 = Russian\n")
  228.                            TEXT ("222 = Thai\n")
  229.                            TEXT ("238 = East European\n")
  230.                            TEXT ("255 = OEM"),
  231.                            szAppName, MB_OK | MB_ICONINFORMATION) ;
  232.                return TRUE ;
  233.  
  234.                // These radio buttons set the lfOutPrecision field
  235.  
  236.           case IDC_OUT_DEFAULT:   
  237.                pdp->lf.lfOutPrecision = OUT_DEFAULT_PRECIS ;  
  238.                return TRUE ;
  239.  
  240.           case IDC_OUT_STRING:
  241.                pdp->lf.lfOutPrecision = OUT_STRING_PRECIS ;  
  242.                return TRUE ;
  243.  
  244.           case IDC_OUT_CHARACTER:
  245.                pdp->lf.lfOutPrecision = OUT_CHARACTER_PRECIS ;  
  246.                return TRUE ;
  247.  
  248.           case IDC_OUT_STROKE:
  249.                pdp->lf.lfOutPrecision = OUT_STROKE_PRECIS ;  
  250.                return TRUE ;
  251.  
  252.           case IDC_OUT_TT:
  253.                pdp->lf.lfOutPrecision = OUT_TT_PRECIS ;  
  254.                return TRUE ;
  255.  
  256.           case IDC_OUT_DEVICE:
  257.                pdp->lf.lfOutPrecision = OUT_DEVICE_PRECIS ;  
  258.                return TRUE ;
  259.  
  260.           case IDC_OUT_RASTER:
  261.                pdp->lf.lfOutPrecision = OUT_RASTER_PRECIS ;  
  262.                return TRUE ;
  263.  
  264.           case IDC_OUT_TT_ONLY:
  265.                pdp->lf.lfOutPrecision = OUT_TT_ONLY_PRECIS ;  
  266.                return TRUE ;
  267.  
  268.           case IDC_OUT_OUTLINE:
  269.                pdp->lf.lfOutPrecision = OUT_OUTLINE_PRECIS ;  
  270.                return TRUE ;
  271.  
  272.                // These three radio buttons set the lfQuality field
  273.  
  274.           case IDC_DEFAULT_QUALITY:
  275.                pdp->lf.lfQuality = DEFAULT_QUALITY ;   
  276.                return TRUE ;
  277.  
  278.           case IDC_DRAFT_QUALITY:
  279.                pdp->lf.lfQuality = DRAFT_QUALITY ;  
  280.                return TRUE ;
  281.  
  282.           case IDC_PROOF_QUALITY:
  283.                pdp->lf.lfQuality = PROOF_QUALITY ;  
  284.                return TRUE ;
  285.  
  286.                // These three radio buttons set the lower nibble
  287.                //   of the lfPitchAndFamily field
  288.  
  289.           case IDC_DEFAULT_PITCH:
  290.                pdp->lf.lfPitchAndFamily = (BYTE)
  291.                     ((0xF0 & pdp->lf.lfPitchAndFamily) | DEFAULT_PITCH) ; 
  292.                return TRUE ;
  293.  
  294.           case IDC_FIXED_PITCH:
  295.                pdp->lf.lfPitchAndFamily = (BYTE)
  296.                     ((0xF0 & pdp->lf.lfPitchAndFamily) | FIXED_PITCH) ; 
  297.                return TRUE ;
  298.  
  299.           case IDC_VARIABLE_PITCH:
  300.                pdp->lf.lfPitchAndFamily = (BYTE)
  301.                     ((0xF0 & pdp->lf.lfPitchAndFamily) | VARIABLE_PITCH) ;  
  302.                return TRUE ;
  303.  
  304.                // These six radio buttons set the upper nibble
  305.                //   of the lpPitchAndFamily field
  306.  
  307.           case IDC_FF_DONTCARE:
  308.                pdp->lf.lfPitchAndFamily = (BYTE)
  309.                     ((0x0F & pdp->lf.lfPitchAndFamily) | FF_DONTCARE) ;  
  310.                return TRUE ;
  311.  
  312.           case IDC_FF_ROMAN:
  313.                pdp->lf.lfPitchAndFamily = (BYTE)
  314.                     ((0x0F & pdp->lf.lfPitchAndFamily) | FF_ROMAN) ;  
  315.                return TRUE ;
  316.  
  317.           case IDC_FF_SWISS:
  318.                pdp->lf.lfPitchAndFamily = (BYTE)
  319.                     ((0x0F & pdp->lf.lfPitchAndFamily) | FF_SWISS) ;  
  320.                return TRUE ;
  321.  
  322.           case IDC_FF_MODERN:
  323.                pdp->lf.lfPitchAndFamily = (BYTE)
  324.                     ((0x0F & pdp->lf.lfPitchAndFamily) | FF_MODERN) ;  
  325.                return TRUE ;
  326.  
  327.           case IDC_FF_SCRIPT:
  328.                pdp->lf.lfPitchAndFamily = (BYTE)
  329.                     ((0x0F & pdp->lf.lfPitchAndFamily) | FF_SCRIPT) ;  
  330.                return TRUE ;
  331.  
  332.           case IDC_FF_DECORATIVE:
  333.                pdp->lf.lfPitchAndFamily = (BYTE)
  334.                     ((0x0F & pdp->lf.lfPitchAndFamily) | FF_DECORATIVE) ;  
  335.                return TRUE ;
  336.  
  337.                // Mapping mode:
  338.  
  339.           case IDC_MM_TEXT:
  340.           case IDC_MM_LOMETRIC:
  341.           case IDC_MM_HIMETRIC:
  342.           case IDC_MM_LOENGLISH:
  343.           case IDC_MM_HIENGLISH:
  344.           case IDC_MM_TWIPS:
  345.           case IDC_MM_LOGTWIPS:
  346.                pdp->iMapMode = LOWORD (wParam) ;
  347.                return TRUE ;
  348.  
  349.                // OK button pressed
  350.                // -----------------
  351.  
  352.           case IDOK:
  353.                     // Get LOGFONT structure
  354.  
  355.                SetLogFontFromFields (hdlg, pdp) ;
  356.  
  357.                     // Set Match-Aspect and Advanced Graphics flags
  358.  
  359.                pdp->fMatchAspect = IsDlgButtonChecked (hdlg, IDC_MATCH_ASPECT) ;
  360.                pdp->fAdvGraphics = IsDlgButtonChecked (hdlg, IDC_ADV_GRAPHICS) ;
  361.  
  362.                     // Get Information Context
  363.  
  364.                if (pdp->iDevice == IDM_DEVICE_SCREEN)
  365.                {
  366.                     hdcDevice = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ;
  367.                }
  368.                else
  369.                {
  370.                     pd.hwndOwner = hdlg ;
  371.                     pd.Flags = PD_RETURNDEFAULT | PD_RETURNIC ;
  372.                     pd.hDevNames = NULL ;
  373.                     pd.hDevMode = NULL ;
  374.  
  375.                     PrintDlg (&pd) ;
  376.  
  377.                     hdcDevice = pd.hDC ;
  378.                }
  379.                     // Set the mapping mode and the mapper flag
  380.  
  381.                MySetMapMode (hdcDevice, pdp->iMapMode) ;
  382.                SetMapperFlags (hdcDevice, pdp->fMatchAspect) ;
  383.  
  384.                     // Create font and select it into IC
  385.  
  386.                hFont = CreateFontIndirect (&pdp->lf) ;
  387.                SelectObject (hdcDevice, hFont) ;
  388.  
  389.                     // Get the text metrics and face name
  390.  
  391.                GetTextMetrics (hdcDevice, &pdp->tm) ;
  392.                GetTextFace (hdcDevice, LF_FULLFACESIZE, pdp->szFaceName) ;
  393.                DeleteDC (hdcDevice) ;
  394.                DeleteObject (hFont) ;
  395.  
  396.                     // Update dialog fields and invalidate main window
  397.  
  398.                SetFieldsFromTextMetric (hdlg, pdp) ;
  399.                InvalidateRect (GetParent (hdlg), NULL, TRUE) ;
  400.                return TRUE ;
  401.           }
  402.           break ;
  403.      }
  404.      return FALSE ;
  405. }
  406. void SetLogFontFromFields (HWND hdlg, DLGPARAMS * pdp)
  407. {
  408.      pdp->lf.lfHeight      = GetDlgItemInt (hdlg, IDC_LF_HEIGHT,  NULL, TRUE) ;
  409.      pdp->lf.lfWidth       = GetDlgItemInt (hdlg, IDC_LF_WIDTH,   NULL, TRUE) ;
  410.      pdp->lf.lfEscapement  = GetDlgItemInt (hdlg, IDC_LF_ESCAPE,  NULL, TRUE) ;
  411.      pdp->lf.lfOrientation = GetDlgItemInt (hdlg, IDC_LF_ORIENT,  NULL, TRUE) ;
  412.      pdp->lf.lfWeight      = GetDlgItemInt (hdlg, IDC_LF_WEIGHT,  NULL, TRUE) ;
  413.      pdp->lf.lfCharSet     = GetDlgItemInt (hdlg, IDC_LF_CHARSET, NULL, FALSE) ;
  414.  
  415.      pdp->lf.lfItalic = 
  416.                     IsDlgButtonChecked (hdlg, IDC_LF_ITALIC) == BST_CHECKED ;
  417.      pdp->lf.lfUnderline = 
  418.                     IsDlgButtonChecked (hdlg, IDC_LF_UNDER)  == BST_CHECKED ;
  419.      pdp->lf.lfStrikeOut = 
  420.                     IsDlgButtonChecked (hdlg, IDC_LF_STRIKE) == BST_CHECKED ;
  421.  
  422.      GetDlgItemText (hdlg, IDC_LF_FACENAME, pdp->lf.lfFaceName, LF_FACESIZE) ;
  423. }
  424.  
  425. void SetFieldsFromTextMetric (HWND hdlg, DLGPARAMS * pdp) 
  426. {
  427.      TCHAR   szBuffer [10] ;
  428.      TCHAR * szYes = TEXT ("Yes") ; 
  429.      TCHAR * szNo  = TEXT ("No") ;
  430.      TCHAR * szFamily [] = { TEXT ("Don't Know"), TEXT ("Roman"),
  431.                              TEXT ("Swiss"),      TEXT ("Modern"),
  432.                              TEXT ("Script"),     TEXT ("Decorative"), 
  433.                              TEXT ("Undefined") } ;
  434.  
  435.      SetDlgItemInt (hdlg, IDC_TM_HEIGHT,   pdp->tm.tmHeight,           TRUE) ;
  436.      SetDlgItemInt (hdlg, IDC_TM_ASCENT,   pdp->tm.tmAscent,           TRUE) ;
  437.      SetDlgItemInt (hdlg, IDC_TM_DESCENT,  pdp->tm.tmDescent,          TRUE) ;
  438.      SetDlgItemInt (hdlg, IDC_TM_INTLEAD,  pdp->tm.tmInternalLeading,  TRUE) ;
  439.      SetDlgItemInt (hdlg, IDC_TM_EXTLEAD,  pdp->tm.tmExternalLeading,  TRUE) ;
  440.      SetDlgItemInt (hdlg, IDC_TM_AVECHAR,  pdp->tm.tmAveCharWidth,     TRUE) ;
  441.      SetDlgItemInt (hdlg, IDC_TM_MAXCHAR,  pdp->tm.tmMaxCharWidth,     TRUE) ;
  442.      SetDlgItemInt (hdlg, IDC_TM_WEIGHT,   pdp->tm.tmWeight,           TRUE) ;
  443.      SetDlgItemInt (hdlg, IDC_TM_OVERHANG, pdp->tm.tmOverhang,         TRUE) ;
  444.      SetDlgItemInt (hdlg, IDC_TM_DIGASPX,  pdp->tm.tmDigitizedAspectX, TRUE) ;
  445.      SetDlgItemInt (hdlg, IDC_TM_DIGASPY,  pdp->tm.tmDigitizedAspectY, TRUE) ;
  446.  
  447.      wsprintf (szBuffer, BCHARFORM, pdp->tm.tmFirstChar) ;
  448.      SetDlgItemText (hdlg, IDC_TM_FIRSTCHAR, szBuffer) ;
  449.  
  450.      wsprintf (szBuffer, BCHARFORM, pdp->tm.tmLastChar) ;
  451.      SetDlgItemText (hdlg, IDC_TM_LASTCHAR, szBuffer) ;
  452.  
  453.      wsprintf (szBuffer, BCHARFORM, pdp->tm.tmDefaultChar) ;
  454.      SetDlgItemText (hdlg, IDC_TM_DEFCHAR, szBuffer) ;
  455.  
  456.      wsprintf (szBuffer, BCHARFORM, pdp->tm.tmBreakChar) ;
  457.      SetDlgItemText (hdlg, IDC_TM_BREAKCHAR, szBuffer) ;
  458.  
  459.      SetDlgItemText (hdlg, IDC_TM_ITALIC, pdp->tm.tmItalic     ? szYes : szNo) ;
  460.      SetDlgItemText (hdlg, IDC_TM_UNDER,  pdp->tm.tmUnderlined ? szYes : szNo) ;
  461.      SetDlgItemText (hdlg, IDC_TM_STRUCK, pdp->tm.tmStruckOut  ? szYes : szNo) ;
  462.  
  463.      SetDlgItemText (hdlg, IDC_TM_VARIABLE, 
  464.                TMPF_FIXED_PITCH & pdp->tm.tmPitchAndFamily ? szYes : szNo) ;
  465.  
  466.      SetDlgItemText (hdlg, IDC_TM_VECTOR, 
  467.                TMPF_VECTOR & pdp->tm.tmPitchAndFamily ? szYes : szNo) ;
  468.  
  469.      SetDlgItemText (hdlg, IDC_TM_TRUETYPE, 
  470.                TMPF_TRUETYPE & pdp->tm.tmPitchAndFamily ? szYes : szNo) ;
  471.  
  472.      SetDlgItemText (hdlg, IDC_TM_DEVICE, 
  473.                TMPF_DEVICE & pdp->tm.tmPitchAndFamily ? szYes : szNo) ;
  474.  
  475.      SetDlgItemText (hdlg, IDC_TM_FAMILY, 
  476.                szFamily [min (6, pdp->tm.tmPitchAndFamily >> 4)]) ;
  477.  
  478.      SetDlgItemInt  (hdlg, IDC_TM_CHARSET,   pdp->tm.tmCharSet, FALSE) ;
  479.      SetDlgItemText (hdlg, IDC_TM_FACENAME, pdp->szFaceName) ;
  480. }
  481.  
  482. void MySetMapMode (HDC hdc, int iMapMode)
  483. {
  484.      switch (iMapMode)
  485.      {
  486.      case IDC_MM_TEXT:       SetMapMode (hdc, MM_TEXT) ;       break ;
  487.      case IDC_MM_LOMETRIC:   SetMapMode (hdc, MM_LOMETRIC) ;   break ;
  488.      case IDC_MM_HIMETRIC:   SetMapMode (hdc, MM_HIMETRIC) ;   break ;
  489.      case IDC_MM_LOENGLISH:  SetMapMode (hdc, MM_LOENGLISH) ;  break ;
  490.      case IDC_MM_HIENGLISH:  SetMapMode (hdc, MM_HIENGLISH) ;  break ;
  491.      case IDC_MM_TWIPS:      SetMapMode (hdc, MM_TWIPS) ;      break ;
  492.      case IDC_MM_LOGTWIPS:
  493.           SetMapMode (hdc, MM_ANISOTROPIC) ;
  494.           SetWindowExtEx (hdc, 1440, 1440, NULL) ;
  495.           SetViewportExtEx (hdc, GetDeviceCaps (hdc, LOGPIXELSX),
  496.                                  GetDeviceCaps (hdc, LOGPIXELSY), NULL) ;
  497.           break ;
  498.      }
  499. }
  500.